﻿using DevExpress.LookAndFeel;
using DevExpress.Pdf;
using DevExpress.Utils;
using DevExpress.Utils.Layout;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors;
using ImageDefine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FrameManager
{
    public static class FrameManager
    {
        public static DevExpress.XtraBars.FluentDesignSystem.FluentDesignFormContainer fluentDesignFormContainer1;

        //public delegate bool InitModuleDelegate();
        //static public event InitModuleDelegate initMuduleEvent;

        public delegate bool SaveProject();
        static public event SaveProject saveProject;
        public delegate bool OpenProject();
        static public event OpenProject openProject;
        public delegate bool SaveAsProject();
        static public event SaveAsProject saveAsProject;

        public delegate void ElementClickEvent(string strElementName);
        static public event ElementClickEvent elementClickEvent;

        //public delegate void ExitApp();
        //static public event ExitApp exitApp;

        public delegate bool ExitingApp();
        static public event ExitingApp exitingApp;

        public static Form FrmStart;

        public static dynamic FrmMain;
        public static FlyoutPanel flyoutPanel;
        public static FlyoutPanelControl flyoutPanelControl;
        public static StackPanel flyoutPanelStack;

        public static List<ImageCalibBase> listImageCalibs;
        public static ProductSetting ProductSetting { get; set; }
        public static void Init()
        {
            ProductSetting = ProductSetting.Load();
        }
        public static void ElementClick(DevExpress.XtraBars.Navigation.ElementClickEventArgs e)
        {
            if (elementClickEvent != null)
            {
                elementClickEvent(e.Element.Name);
 
            }
        }
        public static bool ExitingAppAction(UserLookAndFeel lookAndFeel)
        {
            if (exitingApp != null)
            {
                if (exitingApp())
                {

                }
                else
                {
                    return false;
                }
            }
            else
            {
                if (XtraMessageBox.Show(lookAndFeel, "Exit OPX FlowGlueMachine App", "Exit Opx_App", MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            return true;
        }

        public static void OpenProjectAction()
        {


            if (openProject != null)
            {
                openProject();
            }

        }
        public static void OpenProjectActionByName(string strProjectName)
        {
            //bOpenProjectByName = true;
            //strOpenProjectName = strProjectName;
            //string strProjectPathTemp = @"D:\WorldProject\" + strProjectName + @"\";
            //if (System.IO.Directory.Exists(strProjectPathTemp) == false)
            //{
            //    MessageBox.Show("不存在" + strProjectName + "的项目");
            //    return;
            //}
            //if (openProject != null)
            //{
            //    openProject();
            //}

        }
        public static void SaveProjectAction()
        {
            //MachineInfoManager.Save();
            if (saveProject != null)
            {
                saveProject();
            }
        }
        public static void SaveAsProjectAction()
        {
            if (saveAsProject != null)
            {
                saveAsProject();
            }
        }

        public static ImageDefine.CameraActionerBase Camera1
        {
            get;
            set;
        }

        public static ZMotion.ZMotionCard MotionCard
        {
            get;set;
        }
        public static void ShowForm(Form form)
        {
            FrmMain.ShowForm(form);
        }
        //public static ImageCalibBase ImageCalib
        //{
        //    get
        //}
    }
}
